package com.caocaog.market.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 商品促销基础信息
 * 此为 ShopPromo 和 ShopPromoHis 的父类
 *
 * @author chechen
 * @date 2021-11-20
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel
public class ShopPromoBase implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "创建人", hidden = true)
    private String createBy;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间", hidden = true)
    private Date createTime;

    @ApiModelProperty(value = "更新人", hidden = true)
    private String updateBy;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新时间", hidden = true)
    private Date updateTime;

    @TableField(update = "%s+1")
    @ApiModelProperty(value = "版本号", hidden = true)
    private Integer lockVersion;

    @Dict(dictTable = "mk_shop_basic", dicText = "name", dicCode = "id")
    @ApiModelProperty(value = "门店id")
    private String shopId;

    @Dict(dicCode = "shop_promo_type")
    @ApiModelProperty(value = "促销类型")
    private String type;

    @ApiModelProperty(value = "促销名称")
    private String name;

    @Dict(dictTable = "mk_merchant_basic", dicText = "name", dicCode = "id")
    @ApiModelProperty(value = "商家id")
    private String merchantId;

    @Dict(dictTable = "mk_site_basic", dicText = "name", dicCode = "id")
    @ApiModelProperty(value = "分站id")
    private String siteId;

    @Dict(dicCode = "shop_promo_status")
    @ApiModelProperty(value = "状态")
    private Integer status;

    @Dict(dicCode = "shop_promo_customer")
    @ApiModelProperty(value = "客户身份")
    private String customer;

    @Dict(dicCode = "shop_promo_model")
    @ApiModelProperty(value = "优惠模式")
    private String model;

    @ApiModelProperty(value = "目标数值（订单金额）")
    private BigDecimal target;

    @ApiModelProperty(value = "折扣值（优惠金额）")
    private BigDecimal discount;

    @Dict(dicCode = "shop_promo_is_sole")
    @ApiModelProperty(value = "是否叠加")
    private Integer isSole;

    public ShopPromoBase(ShopPromoBase shopPromoBase) {
        this.createBy = shopPromoBase.createBy;
        this.createTime = shopPromoBase.createTime;
        this.updateBy = shopPromoBase.updateBy;
        this.updateTime = shopPromoBase.updateTime;
        this.lockVersion = shopPromoBase.lockVersion;
        this.shopId = shopPromoBase.shopId;
        this.type = shopPromoBase.type;
        this.name = shopPromoBase.name;
        this.merchantId = shopPromoBase.merchantId;
        this.siteId = shopPromoBase.siteId;
        this.status = shopPromoBase.status;
        this.customer = shopPromoBase.customer;
        this.model = shopPromoBase.model;
        this.target = shopPromoBase.target;
        this.discount = shopPromoBase.discount;
        this.isSole = shopPromoBase.isSole;
    }
}
